package classes.Commands
{
	import components.editor.c_baseEditor;
	import components.editor.c_baseElement;
	import components.editor.c_multiLayerElement;
	
	import flash.display.Bitmap;
	
	public class c_newMultiLayerCommand extends c_deleteAll {
		private var _bitmaps		: Array;
		private var _depths			: Object;
		private var _index			: int;
		
		public function c_newMultiLayerCommand(a_editor: c_baseEditor, a_bitmaps: Array, a_depths: Object) {
			super(a_editor);
			_bitmaps	= a_bitmaps;
			_depths	 	= a_depths;
		}
		
		override public function Execute():void {
			super.Execute();
			if (!_element) {
				_element 	= new c_multiLayerElement(editor.imageLayer, _bitmaps, _depths);
				_element.x	= (editor.imageLayer.width - _element.width) / 2;
				_element.y	= (editor.imageLayer.height - _element.height) / 2;
				_index = _element.index;
			} else _element.setParent(editor.imageLayer, _index);
			editor.dragRect.link = _element;
		}
		
		override public function unExecute():void {
			_element.remove();
			super.unExecute();
		}
		
		override public function dispose():void {
			super.dispose();
			_element.dispose();
		}
	}
}